#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MATCH_FALSE -1
#define MATCH_TRUE  0


const int stringsize = 1024;

void BuildNext(int *next, const char *t){
    int sz = strlen(t);
    int i = 0; int j = -1;
    
    next[0] = -1;
    while(i < sz && j < sz){
	if(j == -1 || t[i] == t[j]){
	    next[i++] = j++;
	}
	else {
            j = next[j];	
	}
    }
}


int KMP_Match(const char *s,const char *t){
    int sz_s = strlen(s);	
    int sz_t = strlen(t);	
    if(sz_s == 0 || sz_t == 0 || sz_t > sz_s) return MATCH_FALSE;
    int *next = (int*)malloc(sizeof(int)*(sz_t + 1));
    BuildNext(next,t);
    int i = 0;int j = 0;
    while(i < sz_s && j < sz_t){
    	if(s[i] == t[j]){
	    ++i;++j;
	}
	else{
            if(j == 0) ++i;
	    j = next[j];
	}
    }
    
    return j == sz_t ? i - sz_t : MATCH_FALSE;


}

int main(){
    char *s = (char*)malloc(stringsize);
    char *t = (char*)malloc(stringsize);
    //fgets(s,stringsize,stdin);
    //fgets(t,stringsize,stdin);
    scanf("%s", s); scanf("%s",t);
    printf("%d\n",KMP_Match(s,t));
    return 0;
}
